package com.oscar.ehome.utils.dowload.entity;



import android.util.Log;


import com.oscar.ehome.utils.dowload.dowload.OnDownload;
import com.oscar.ehome.utils.dowload.progressbar.RoundProgressBar;

import java.io.Serializable;

/**
 */
public class TaskInfo  implements Serializable {

    private String tag = "TaskInfo";
    private String url;
    private String filePath;
    private String fileName;
    private int lenght;
    private OnDownload download;
    private String bookid;

    public RoundProgressBar getPb() {
        return pb;
    }

    public void setPb(RoundProgressBar pb) {
        this.pb = pb;
    }

    private RoundProgressBar pb;

    
    /**
     * 单例模式
     */
    private TaskInfo() {
    }

    private static TaskInfo observable;

    public static TaskInfo getObservable() {

        if (observable == null) {
            observable = new TaskInfo();
        }
        return observable;
    }
    
    
   
    
    
    
    public TaskInfo(String url, String filePath,String fileName,int lenght, OnDownload download,String bookid,RoundProgressBar pb) {
        this.url = url;
        this.filePath = filePath;
        this.fileName = fileName;
        this.lenght = lenght;
        this.download = download;
        this.bookid = bookid;
        this.pb = pb;
        
    }
    
    public TaskInfo(String url, String filePath,int lenght, OnDownload download,String bookid) {
        this.url = url;
        this.filePath = filePath;
        this.lenght = lenght;
        this.download = download;
        this.bookid = bookid;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public String getFilePath() {
        return filePath;
    }

    public void setFilePath(String filePath) {
        this.filePath = filePath;
    }

    public OnDownload getDownload() {
        return download;
    }

    public void setDownload(OnDownload download) {
        this.download = download;
    }

    public String getFileName() {
        return fileName;
    }

    public void setFileName(String fileName) {
        this.fileName = fileName;
    }

    public int getLenght() {
        return lenght;
    }

    public void setLenght(int lenght) {
        this.lenght = lenght;
    }
    
    

    public String getBookid() {
		return bookid;
	}

	public void setBookid(String bookid) {
		this.bookid = bookid;
	}
	


	int objectHashCode(Object obj){

        if (obj == null)
        {
            return 0;
        }
        return obj.hashCode();
    }

    int arrayHashCode(Object[] objs)
    {
        int result = 0;
        if (objs == null)
        {
            return result;
        }
        for (Object o : objs)
        {
            result += objectHashCode(o);
        }
        return result;
    }


    @Override
    public String toString() {
        return "TaskInfo{" +
                "url='" + url + '\'' +
                ", filePath='" + filePath + '\'' +
                ", fileName='" + fileName + '\'' +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if(this == o) {
            return true;
        }
        if(null == o || (! (o instanceof TaskInfo))) {
            return false;
        }
        TaskInfo info = (TaskInfo)o;
        if(info.getUrl() == null ){
            return false;
        }
        return info.getUrl().equals(url);


    }

    @Override
    public int hashCode() {
        int result = 17;
        result = 37 * result + objectHashCode(url);
        Log.i(tag,"hashcode = "+result);
        return result;
    }
}
